The Danish driver will race a BMW M Hybrid V8 in a yet-to-be-confirmed series.
BMW currently competes in the FIA World Endurance Championship and IMSA SportsCar Championship.
BMW will confirm its full driver line-up in due course.
“I am happy and proud to represent such an iconic motorsport brand as BMW in some of the world’s most legendary races,” said Magnussen.
“After 10 years in Formula 1, I am embarking on a new and exciting chapter, and I look forward to taking on the challenge in the most innovative and advanced sports cars in the history of endurance racing.
“A huge thank you to BMW M Motorsport for this fantastic opportunity. I can hardly wait to start the preparations and look forward to kicking off the 2025 season with the rest of the team.”
Magnussen will end a storied F1 career after the Abu Dhabi Grand Prix with Haas.
The 32-year-old began his career in 2014 with McLaren, scoring second on debut in the Australian Grand Prix. It remains his only F1 podium finish.
Magnussen was dropped for the 2015 season before joining Renault in 2016. That lasted just one season before joining Haas in 2017.
The appointment at BMW will afford him the opportunity to compete for outright victory in either the Daytona 24 or 24 Hours of Le Mans.
BMW M Motorsport head Andreas Roos welcomed Magnussen to the team.
“Kevin Magnussen is an outstanding addition to our LMDh programme,” said Roos.
“He has regularly demonstrated his speed at the highest level in Formula 1 over the past decade.
“Thanks to his extensive experience, he is a true asset to our project.
“His previous full season with a sports car prototype in 2021 is another advantage for us, as it will surely ease his acclimatisation to the BMW M Hybrid V8.
“I am very delighted that Kevin Magnussen is part of the BMW M Motorsport family now.”